<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <button onclick="stop()">停止打印</button>
    <script>
        var timer = setInterval(function () {
            var now = new Date();
            console.log(now.toLocaleString())
        }, 1000)
        function stop(){
            setTimeout(function(){
                clearInterval(timer)
            },5000)
        }
    </script>

    <script>
        // 随机点名
        var arr = ['张三','李四','王五'];
        var num =Math.floor(Math.random() * arr.length)
        console.log(arr[num]);

        var n = Math.ceil(2.1);
        console.log( n );
        console.log(Math.floor(5.9))
        // 给出一个10-50(包含50)之间的随机整数
        // var num =10 + parseInt(Math.random() * 41);
        var num =10 + Math.round(Math.random() * 40);

        // 日期对象
        var now = new Date();
        console.log(now)
        console.log( now.toLocaleString() )
        var year = now.getFullYear();
        var month = now.getMonth();//获取的月份比实际月份小1
        var date = now.getDate();
        console.log(year,month,date)
        console.log(year +'-'+(month+1)+'-'+date);

        // window.alert('你好')
        // var isClose = confirm('你确定要关闭浏览器吗')
        // console.log(isClose)
        // var content= prompt('请输入一个数字',600);
        // 输入框获取的值都是字符串类型的
        // if(content){
        //     console.log( parseInt(content)+100 ) 
        // }
    </script>
</body>
</html>